package com.mall.sun.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.sun.model.dto.AgentDTO;
import com.mall.sun.model.dto.GoodAgentDTO;
import com.mall.sun.model.dto.PageHelper;
import com.mall.sun.model.po.Agent;
import com.mall.sun.repository.mapper.AgentMapper;
import com.mall.sun.service.AgentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Tansty
 * @since 2021-11-30
 */
@Service
public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements AgentService {
    @Autowired
    AgentMapper agentMapper;
    @Override
    public int updateAgent(GoodAgentDTO goodAgentDTO) {
        return agentMapper.updateAgent(goodAgentDTO);
    }

    @Override
    public Long countAgent() {
        return agentMapper.countAgent();
    }

    @Override
    public Agent[] getAllAgent(PageHelper pageHelper) {
        Page<AgentDTO> agentPage = new Page<>(pageHelper.getCurrentPage(),pageHelper.getPageSize());
        return agentMapper.getAllAgent(agentPage);
    }

    @Override
    public AgentDTO[] searchAgent(String aName) {
        return agentMapper.searchAgent(aName);
    }

    @Override
    public int updateAgentPo(Agent agent) {
        return agentMapper.updateAgentPo(agent);
    }

    @Override
    public int deleteAgent(AgentDTO agentDTO) {
        return agentMapper.deleteAgent(agentDTO);
    }

    @Override
    public int insertAgentPo(Agent agent) {
        return agentMapper.insertAgentPo(agent);
    }

    @Override
    public Agent[] getAllAgentDesc(PageHelper pageHelper) {
        Page<AgentDTO> agentPage = new Page<>(pageHelper.getCurrentPage(),pageHelper.getPageSize());
        agentPage.setDesc("agent_Id");
        return agentMapper.getAllAgent(agentPage);
    }
}
